<include file="Public:header" />
<div style="boder:1px solid #ccc;margin:10px 10px 0px 10px;">
    <div style="border:1px solid #ccc;height:40px;padding:0 0 0 20px;line-height:40px;">
           编辑产品信息 Edit Product Arrondi
    </div>
    <form action="{:U('WebsiteContentManage/index')}" method="post">
    <div style="border:1px solid #ccc;height:auto;padding:10px 0px 10px 13px;margin-top:5px;"> 
                    <select name="column_id">
					    <option value="0">请选择栏目</option>
                        <foreach name="columnName" item="val">
                        <option value="{$val.id}" <if condition="$val.id eq $column_id">selected</if> >{$val.column_name}</option>
                        </foreach>
                    </select>
                    <input type="submit" name="show" value="显示" />
    </div>
	</form> 
    <div style="border:1px solid #ccc;margin:5px 0px 5px 0px;padding:5px 0px 5px 10px;">
        <form action="{:U('WebsiteContentManage/manageProductArrondi')}" method="post" >
        <table>
		      <tr>
			       <td colspan="4">
				       
                       <input type="submit" name="save" value="保存" />
                
                       <input type="reset" value="重置" />
				   </td>
              </tr>
              <volist name="productResult" id ="val">
              <tr>
                  <th>产品名称：</th>
                  <td>
                      <input type="hidden" name="column_id" value="{$column_id}" />
                      <input type="hidden" name="id[]" value="{$val.id}" />
                      <input type="text" name="product_name[]" value="{$val.product_name}" size="50" />
                  </td>
              </tr>
              <tr>
                  <th>产品货号：</th>
                  <td>
                      <input type="text" name="product_num[]" value="{$val.product_num}" size="50" />
                  </td>
              </tr>
              <tr>
                  <th>产品颜色：</th>
                  <td>
                      
                      <div id="fileUpload_{$val.id}" style="float:left;border:0px solid #ccc;">
                          <volist name="val['product_color']" id="v" key="k">
                          <div id="color_{$val.id}_{$k}" style="border:0px solid #ccc;width:auto;float:left;height:24px;">
                              <div id="plus" onclick="plus('color_{$val.id}_{$k}','{$val.id}')" style="border:0px solid #ccc;width:18px;height:18px;background:url('__PUBLIC__/Images/product/minus.gif') no-repeat 0 0;float:left;margin:3px 5px 0px 5px;"></div>
                                        <input type="hidden" name="colors[{$val.id}][]" id="colValue_{$val.id}_{$k}" value="{$v}" />
                                        <div id="bgcolor_{$val.id}_{$k}" style="background-color:{$v};border:1px solid #ccc;width:18px;height:18px;float:left;margin:3px 5px 0px 0px;"></div>
                                        <input type="button" id="changeColor_{$val.id}_{$k}" onclick="colorBan('changeColor_{$val.id}_{$k}','bgcolor_{$val.id}_{$k}','colValue_{$val.id}_{$k}')" value="选择颜色" style="float:left;" />
                                        <div id="minus" onclick="minus('color_{$val.id}_{$k}','{$val.id}')" style="border:0px solid #ccc;width:18px;height:18px;background:url('__PUBLIC__/Images/product/plus.gif') no-repeat 0 0;float:left;margin-top:3px;"></div>
                                    </div>
                          </volist>
                      </div>
                  </td>
              </tr>
              <tr>
                  <th>产品尺码：</th>
                  <td>
                      <input type="text" name="product_size[]" value="{$val.product_size}" size="50" />
                  </td>
              </tr>
              <tr>
                  <th>产品材质：</th>
                  <td>
                      <input type="text" name="product_material[]" value="{$val.product_material}" size="50" />
                  </td>
              </tr>
              <tr>
                  <th>产品成分：</th>
                  <td>
                      <input type="text" name="product_composition[]" value="{$val.product_composition}" size="50" />
                  </td>
              </tr>
              <tr>
                  <th>产品简介：</th>
                  <td><textarea id="product_describe_{$val.id}" name="product_describe[]" style="width:800px;height:245px;visibility:hidden;">{$val.product_describe}</textarea></td>
              </tr>
              <tr>
                  <th>创建时间：</th>
                  <td>
                      <input type="text" name="create_time[]" value="<if condition='$val.create_time neq ""'>{$val.create_time}<else/><php>echo date('Y-m-d H:i:s');</php></if>" readonly="readonly"/>
                  </td>
              </tr>
              <script type="text/javascript">
                    KindEditor.ready(function(K){
                            K.create('#product_describe_{$val.id}');
                    });
              </script>
              </volist>
        </table> 
    </div>
    </form>
</div>
    <script type="text/javascript">
          var num = {$num};
          function plus(id,vv){
              //alert(vv);
              if(jq("#fileUpload_"+vv+" input").length -2 == 0){
                  //alert(vv);alert("asdfas");exit;
                  var str = '<div id="color_'+num+'" style="border:0px solid #ccc;width:auto;float:left;height:24px;"><div id="plus" onclick="plus('+"'"+'color_'+num+"','"+vv+"'"+')"'+'style="border:0px solid #ccc;width:18px;height:18px;background:url('+'__PUBLIC__/Images/product/minus.gif'+') no-repeat 0 0;float:left;margin:3px 5px 0px 5px;"></div><input type="hidden" name="colors['+vv+'][]" id="colValue_'+num+'" value="" /><div id="bgcolor_'+num+'" style="border:1px solid #ccc;width:18px;height:18px;float:left;margin:3px 5px 0px 0px;"></div><input type="button" id="changeColor_'+num+'" onclick="colorBan('+"'"+"changeColor_"+num+"','"+'bgcolor_'+num+"','colValue_"+num+"'"+')" value="选择颜色" style="float:left;" /><div id="minus" onclick="minus('+"'"+'color_'+num+"','"+vv+"'"+')" style="border:0px solid #ccc;width:18px;height:18px;background:url('+"'__PUBLIC__/Images/product/"+'plus.gif'+"'"+') no-repeat 0 0;float:left;margin-top:3px;"></div></div>';
                  jq("#fileUpload_"+vv).html(str);
                  num++;
              }else{
                  jq("#"+id).remove();
              }
          } 
  
          function minus(id,vv){
              var str = '<div id="color_'+num+'" style="border:0px solid #ccc;width:auto;float:left;height:24px;"><div id="plus" onclick="plus('+"'"+'color_'+num+"','"+vv+"'"+')"'+'style="border:0px solid #ccc;width:18px;height:18px;background:url('+'__PUBLIC__/Images/product/minus.gif'+') no-repeat 0 0;float:left;margin:3px 5px 0px 5px;"></div><input type="hidden" name="colors['+vv+'][]" id="colValue_'+num+'" value="" /><div id="bgcolor_'+num+'" style="border:1px solid #ccc;width:18px;height:18px;float:left;margin:3px 5px 0px 0px;"></div><input type="button" id="changeColor_'+num+'" onclick="colorBan('+"'"+"changeColor_"+num+"','"+'bgcolor_'+num+"','colValue_"+num+"'"+')" value="选择颜色" style="float:left;" /><div id="minus" onclick="minus('+"'"+'color_'+num+"','"+vv+"'"+')" style="border:0px solid #ccc;width:18px;height:18px;background:url('+"'__PUBLIC__/Images/product/"+'plus.gif'+"'"+') no-repeat 0 0;float:left;margin-top:3px;"></div></div>';
              jq("#"+id).after(str);
              num++;
          }

          function colorBan(pos,id,val) {
				var colorpicker;
					if (colorpicker) {
						colorpicker.remove();
						colorpicker = null;
					}
					var colorpickerPos = KindEditor('#'+pos).pos();
					colorpicker = KindEditor.colorpicker({
						x : colorpickerPos.x,
						y : colorpickerPos.y + KindEditor('#'+pos).height(),
						z : 19811214,
						selectedColor : 'default',
						noColor : '无颜色',
						click : function(color) {
                            KindEditor('#'+id).css("background-color",color);
                            KindEditor('#'+val).val(color);
							colorpicker.remove();
							colorpicker = null;
						}
                        });
                  //  });
           }
      </script>
  </body>
</html>

